<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3.延伸函数环境生命周期</title>
</head>

<body>
  <script>
    function hd () {
      let n = 1;
      return function sum () {
        let m = 1;
        return function() {
          console.log(++n);
          console.log(++m);
        }
      };
    }
    let a  = hd()();
    // 父级的两个函数内部的变量因为子函数被引用的原因得以保留
    a(); //2,2 
    a(); //3,3 
  </script>
</body>

</html>